package tamavo.dao
{
	import mx.collections.ArrayCollection;
	import mx.rpc.events.ResultEvent;
	
	import tamavo.context.Context;
	import tamavo.entities.Plan;

	public class PlanDAO
	{
		private var event:ResultEvent;
		
		public function PlanDAO(){
			event = Context.getAttribute("eventXML");
		}
		
		public function findAll():ArrayCollection{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var p:Object in event.result.tbd.plans.plan){
				ac.addItem(processRow(p));
			}
			return ac;
		}
		
		protected function processRow(o:Object):Object{
			var plan:Plan = new Plan();
			plan.id = o.id;
			plan.name = o.name;
			plan.procs = o.processes;
			return plan;
		}
	}
}